<?php
/**
 * 宠物猫、宠物狗的引用类
 */

namespace Xxb\XxbPhpAlgo\Topic;

class CatDog
{
    /**
     * @var Cat|Dog 具体的宠物实例
     */
    private $pet;

    /**
     * @var int 宠物实例编号
     */
    public $num;

    public function __construct($pet, $num)
    {
        if (!($pet instanceof Pet)) {
            throw new \TypeError('init error, illegal pet.');
        }
        $this->pet = $pet;
        $this->num = $num;
    }

    public function getPet()
    {
        return $this->pet;
    }
}
